<!--  -->
<template>
    <div class='all'>
        <el-button type="text"
            style="position: absolute; top: 0;left: 15px;font-size: 0.37rem;font-weight: bold;color: #606266;"
            @click="ESC()">返回</el-button>
        <div style="margin-top: 15%;">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="垛位号" style="font-weight: bold;">
                    <el-select v-model="form.dwNum" placeholder="请选择垛位号" style="width: 85%;">
                        <el-option ref="DwNumber" v-for="item in form.SelArr" :key="item" :label="item"
                            :value="item"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="件次号" style="font-weight: bold;">
                    <el-input v-model="form.jcNum" style="width: 85%;"></el-input>
                </el-form-item>
            </el-form>
            <div>
                <el-button plain @click="resize()">重输</el-button>
                <el-button plain @click="Enter()">入库</el-button>
            </div>

            <div style="margin-top: 5%;" @change="xz">
                <el-radio v-model="radio" :label="1">扫描</el-radio>
                <el-radio v-model="radio" :label="2">手输</el-radio>
            </div>
            <div style="margin-top: 5%;">
                <el-button plain @click="GoPage()">详细信息</el-button>
                <el-button plain @click="StorageRoom()">库房信息</el-button>
            </div>
        </div>


    </div>
</template>

<script>
import $ from 'jquery';
import 'jquery.soap';
export default {
    name: 'PageTwo',
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
        //这里存放数据
        return {
            form: {
                jcNum: '',
                dwNum: '',
                SelArr: []


            },
            radio: 2,

        };
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
        xz() {

            if (this.radio == 1) {
                this.$router.push('/scanCode')
            }
        },
        ESC() {
            window.history.go(-1);
        },
        Enter() {
            var val = this.form.jcNum.slice(1);
            var val2 = sessionStorage.getItem('LoginUser').split(',')[1]
            console.log(val, '2');

            $.soap({
                url: 'api/pdaservices/services/location?',
                method: 'RecMaterial',
                data: {
                    in0: val2,
                    in1: this.form.dwNum,
                    in2: val,
                    in3: '1'
                },
                success: function (res) {
                    var text = res.content.all;
                    console.log(text,'11');
                    for (var i = 0; i < text.length; i++) {
                        if (text[i].nodeName == "xsd:anyType") {

                            alert(text[text.length - 1].innerHTML);
                            break;
                        }
                    }
                }
            })
        },
        resize() {
            this.form.jcNum = '';
        },
        GoPage() {
            this.$router.push({ path: '/Page9', query: { val: this.form.jcNum.slice(1), val2: this.form.dwNum } })
        },
        StorageRoom() {
            this.$router.push('/PageTable')

        }
    },

    //生命周期 - 创建完成（可以访问当前this实例）
    created() {

    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {
        var ID = sessionStorage.getItem('LoginUser').split(',')[1];
        var arr;
        var that = this;

        this.$nextTick(() => {
            $.soap({
                url: 'api/pdaservices/services/location?',
                method: 'getLocation',
                data: {
                    in0: ID
                },
                success: function (res) {
                    var val = res.content.all;
                    arr = [];
                    for (var i = 0; i < val.length; i++) {
                        if (val[i].nodeName == "xsd:anyType") {
                            arr.push(val[i].innerHTML)
                        }
                    }
                    arr.shift();
                    that.form.SelArr = arr;

                }
            })
            var jch = sessionStorage.getItem('jc');
            if (jch) {
                this.form.jcNum = jch
            } else {
                sessionStorage.removeItem('jc');

            }

        })


    },
    beforeCreate() { }, //生命周期 - 创建之前
    beforeMount() { }, //生命周期 - 挂载之前
    beforeUpdate() { }, //生命周期 - 更新之前
    updated() { }, //生命周期 - 更新之后
    beforeDestroy() { }, //生命周期 - 销毁之前
    destroyed() { }, //生命周期 - 销毁完成
    activated() { }, //如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style lang='scss' scoped>
.el-select {
    width: 100%;
}

.all {
    font-size: 0.37rem;
    font-weight: bold;
    color: #606266;
    ;
}
</style>